<template>
  <the-table ref="table" :columns="columns" uri="a/sub-admins">
    <span slot="action" slot-scope="{ row }">
      <a @click="edit(row)"><a-icon type="edit" /> 编辑 </a>
      <a @click="perms(row)" class="ml-2"><a-icon type="safety" /> 权限 </a>
      <a-popconfirm
        class="ml-2"
        title="确定删除？"
        ok-text="是"
        cancel-text="否"
        @confirm="confirmDel(row.id)"
      >
        <a class="red"> <a-icon type="delete" />删除 </a>
      </a-popconfirm>
    </span>
  </the-table>
</template>
<script>
import theTable from '@/components/theTable.vue'

const columns = [
  {
    title: 'ID',
    dataIndex: 'id',
  },

  // {
  //   title: '编码',
  //   dataIndex: 'code',
  // },

  {
    title: '用户名',
    dataIndex: 'username',
  },

  {
    title: '电话',
    dataIndex: 'mobile',
  },

  // {
  //   title: 'FCB',
  //   dataIndex: 'coins',
  // },

  // {
  //   title: '卖币手续费率',
  //   dataIndex: 'fee_ratio',
  // },

  // {
  //   title: '下发手续费',
  //   dataIndex: 'tip',
  // },

  {
    title: '创建时间',
    dataIndex: 'created_at',
  },

  {
    title: '操作',
    key: 'action',
    scopedSlots: { customRender: 'action' },
    width: 200,
  },
]

export default {
  components: { theTable },

  data() {
    return {
      columns,
    }
  },
  computed: {},
  mounted() {},
  methods: {
    edit(row) {
      this.$emit('on-edit', row)
    },
    perms(row) {
      this.$emit('on-perms', row)
    },
    confirmDel(id) {
      this.axios.delete(`/a/sub-admins/${id}`).then((res) => {
        this.$message.success('删除成功')
        this.refresh()
      })
    },
    refresh() {
      this.$refs.table.onRefresh()
    },
  },
}
</script>
